

import java.io.IOException;

import pjaws.paw.Paw;



public class TestPawServer extends Paw{
	public TestPawServer(String initFile){
		super(initFile);
	}
	
	public static void main(String args[]){
		String initFile = System.getProperty("user.dir")  + "/testserver.paw";
		System.out.println(initFile);
		Paw myPaw = new TestPawServer(initFile);	
		
		//initialize data
		int setlen = 1000000; //a 1 million integers!
		int[] set1 = new int[setlen];
		int[] set2 = new int[setlen];
		for (int i = 0; i < setlen; i++){
			set1[i] = i;
			set2[i] = i + setlen;
		}
				
		int overall_max = 0;

		try {
			//send set1 to client
			myPaw.sendPawMessage(set1, 121, 1);
			System.out.println("SENT: " + set1);
			
			//send set2 to client2
			myPaw.sendPawMessage(set2, 123, 1);
			System.out.println("SENT: " + set2);
			
			//receive max1 from client
			int max1 = (Integer) myPaw.receivePawMessage(121, 2);
			System.out.println("The Client 1 Max is: " + max1);
			overall_max = max1;
			
			//receive max2 from client
			int max2 = (Integer) myPaw.receivePawMessage(123, 2);
			System.out.println("The Client 2 Max is: " + max2);
			if (max2 > overall_max){
				overall_max = max2;
			}
			
			System.out.println("OVERALL_MAX is: " + overall_max);
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		
	}

}

